<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
	pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="style.css" media="screen" />
<title>Hammer Time Auctions</title>
<script language="javascript" type="text/javascript">
	function registerClicked() {
		javascript: add_item.submit();
	}
</script>
</head>
<body>
	<div id="content">
		<%@include file="header.jsp"%>
		<h1>Add An Item</h1>
		<hr></hr>
		<div class="sidebar right margin-5px padding-5px">
			<%
				// Display the list of registration errors if there are any.
				if (session.getAttribute("register_errors") != null) {
					out.println("<div class=\"section padding-5px error-text\">");
					out.println(session.getAttribute("register_errors"));
					out.println("</div>");
				}
				// Check if there were previously entered values for the form. If there aren't then use an
				// empty string.
				if (session.getAttribute("name") == null) {
					session.setAttribute("name", "");
				}
				if (session.getAttribute("year") == null) {
					session.setAttribute("year", "");
				}
				if (session.getAttribute("type") == null) {
					session.setAttribute("type", "");
				}
				if (session.getAttribute("description") == null) {
					session.setAttribute("description", "");
				}
			%>
		</div>
		<%
			// Create a back button.
			out.println("<a href=\"view_items.jsp\" class=\"margin-5px button\">Back</a>");
		%>
		<div class="center" id="register-box">
			<form name="add_item" action="add_item_validate.jsp" method="post"
				enctype="multipart/form-data">
				<table>
					<tr>
						<td><label class="form-label" for="name">Name:</label></td>
						<td><input name="name" type="text"
							value="<%=session.getAttribute("name")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="year">Year:</label></td>
						<td><input name="year" type="text"
							value="<%=session.getAttribute("year")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="type">Type:</label></td>
						<td><input name="type" type="text"
							value="<%=session.getAttribute("type")%>" /></td>
					</tr>
					<tr>
						<td><label class="form-label" for="description">Description:</label></td>
						<td><textarea name="description" rows="6" cols="35"><%=session.getAttribute("description")%></textarea></td>
					</tr>
					<tr>
						<td><label class="form-label" for="picture">Picture: </label></td>
						<td><input name="picture" type="file" accept="image/*" /></td>
					</tr>
					<tr>
						<td></td>
						<td><a href="#" class="left button" type="submit"
							onclick="return registerClicked()">Add Item</a></td>
					</tr>
				</table>
				<input type="submit" class="hidden" />
			</form>
		</div>
	</div>
	<%
		// Clear all the attributes after they have been read.
		session.setAttribute("register_errors", null);
		session.setAttribute("name", null);
		session.setAttribute("type", null);
		session.setAttribute("year", null);
		session.setAttribute("description", null);
	%>
	<hr></hr>
	<%@include file="footer.jsp"%>
</body>
</html>